program MaxplusMin;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
  n, i, max, min: integer;
  mass:array of integer;

begin
  max:=0;
  readln('n');
  setlength(mass, n);
  for i:=0 to n-1 do
    readln(mass[i]);
  for i:=0 to n-1 do
  begin
    if mass[i]>max then
      max:=mass[i};
  end;
  min:=max;
  for i:=0 to n-1 do
  begin
    if mass[i]<min then
      min:=mass[i];
  end;
  write(min+max);
  readln();
end.
 